import java.util.HashMap;
import java.util.LinkedList;


public class Nullp extends Expr {
	private Expr e;
	
	public Nullp(Expr e) {
		this.e = e;
	}

    public Element eval(HashMap<String, Element> nametable, HashMap<String, Proc> functiontable, LinkedList var) {
    	Element list = e.eval(nametable, functiontable, var);
    	
    	if (!list.isList()) {
    		throw new IllegalStateException("Expression does not evaluate to a list.");
    	}
    	
    	return new Element(list.getListValue().getSequence().numElements() == 0 ? 1 : 0);
    }
}
